package com.design.chain;

import java.math.BigDecimal;

/**
 * 组装执行处理
 *
 * @author <a href="jiangfeng.yan@ikang.com">jiangfeng</a>
 * @version 2022年01月21日 下午 2:20
 */
public class HandlerMain {
    public static void main(String[] args) {
        // 构造责任链:
        HandlerChain chain = new HandlerChain();
        chain.addHandler(new ManagerHandler());
        chain.addHandler(new DirectorHandler());
        chain.addHandler(new CEOHandler());
        // 处理请求:
        boolean bob = chain.process(new Request("Bob", new BigDecimal("123.45")));
        System.out.println("bob = " + bob);
        boolean alice = chain.process(new Request("Alice", new BigDecimal("1234.56")));
        System.out.println("alice = " + alice);
        boolean bill = chain.process(new Request("Bill", new BigDecimal("12345.67")));
        System.out.println("bill = " + bill);
        boolean john = chain.process(new Request("John", new BigDecimal("123456.78")));
        System.out.println("john = " + john);
    }
}
